package com.cise.searcher;

import java.util.ArrayList;
import java.util.List;

import com.cise.utils.Util;

import net.semanticmetadata.lire.ImageSearcher;

/**
 * ��������������
 * @author ����
 *
 */
public class ParallelSearcherFactory {
	
	/**
	 * �������õ������㷨��������������
	 * @param algorithms
	 * @return
	 */
	public static AbstractParallelSearcher createParallelSearcher(List<String> algorithms){
		switch(Util.getSortName()){
		case Util.RANK_SORT_NAME:
			return createRankParallelSearcher(algorithms);
		case Util.RATIO_SORT_NAME:
			return createRatioParallelSearcher(algorithms);
		case Util.LINEAR_SORT_NAME:
			return createLinearParallelSearcher(algorithms);
		default:
			return createDefaultParallelSearcher(algorithms);
		}
	}
	/**
	 * ��������RankSort�����㷨�Ĳ���������
	 * @param searchers
	 * @return AbstractParallelSearcher
	 */
	public static AbstractParallelSearcher createRankParallelSearcher(List<String> algorithms){
		AbstractParallelSearcher aps = new RankParallelSearcher();
		aps.setIndexPaths(algorithms);
		return aps;
	}
	
	/**
	 * ����Ĭ�ϲ���������
	 * @param searchers
	 * @return AbstractParallelSearcher
	 */
	public static AbstractParallelSearcher createDefaultParallelSearcher(List<String> algorithms){
		return createRankParallelSearcher(algorithms);
	}
	
	/**
	 * ��������RatioSort�����㷨�Ĳ���������
	 * @param searchers
	 * @return AbstractParallelSearcher
	 */
	public static AbstractParallelSearcher createRatioParallelSearcher(List<String> algorithms){
		AbstractParallelSearcher aps = new RatioParallelSearcher();
		aps.setIndexPaths(algorithms);
		return aps;
	}
	
	/**
	 * �������� LinearSort �����㷨�Ĳ���������
	 * @param algorithms
	 * @return
	 */
	public static AbstractParallelSearcher createLinearParallelSearcher(List<String> algorithms){
		AbstractParallelSearcher aps = new LinearParallelSearcher();
		aps.setIndexPaths(algorithms);
		return aps;
	}
	
	/**
	 * �������� LinearSort �����㷨�Ĳ���������
	 * @param algorithms
	 * @return
	 */
	public static AbstractParallelSearcher createTestLinearParallelSearcher(List<String> algorithms, double[] featureWeight){
		AbstractParallelSearcher aps = new LinearParallelSearcher(featureWeight);
		aps.setIndexPaths(algorithms);
		return aps;
	}
}
